﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Jitter;
using Microsoft.Xna.Framework;
using X13.Libs;
using X13.Player;

namespace X13
{
    public static class ObjectHolder
    {
        public static PlayerHUB PlayerCenter;
        public static Game ParentGame;
        public static World GameWorld;
        public static Camera GameCamera;

        static ObjectHolder()
        {
            GameWorld = new World(new Jitter.Collision.CollisionSystemSAP());
            GameWorld.Gravity = Converter.ConvertVect(Globals.Gravity);
        }

        public static void Load(Game game)
        {
            PlayerCenter = new PlayerHUB();
            if (File.Exists(game.Content.RootDirectory + @"\data\$userdata.dat"))
                PlayerCenter.Deserialize();

            game.Exiting += (s, e) => { PlayerCenter.Serialize(); };
        }
    }
}
